package com.hjq.demo.ryquick.custom;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.hjq.demo.R;

import java.util.List;

import io.rong.imkit.conversationlist.model.BaseUiConversation;
import io.rong.imkit.conversationlist.provider.BaseConversationProvider;
import io.rong.imkit.widget.adapter.IViewProviderListener;
import io.rong.imkit.widget.adapter.ViewHolder;
import io.rong.imlib.model.Conversation;

/**
 * author: jiahe
 * 创建时间: 2022/2/14
 * Des:
 */
public class MyConversationProvider extends BaseConversationProvider {
    @Override
    public boolean isItemViewType(BaseUiConversation item) {
        //根据业务需要，判断 item 是该模板需要处理的会话时，返回 true, 否则返回 false
        //此处以自定义私聊会话模板为例
        return item.mCore.getConversationType().equals(Conversation.ConversationType.PRIVATE);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        //根据业务需要，自定义处理
        return super.onCreateViewHolder(parent, viewType);
    }

    @Override
    public void bindViewHolder(ViewHolder holder, BaseUiConversation uiConversation, int position, List<BaseUiConversation> list, IViewProviderListener<BaseUiConversation> listener) {
        //根据业务需要，自定义处理
        super.bindViewHolder(holder, uiConversation, position, list, listener);
        ImageView ivLevel = holder.getView(R.id.iv_level);
        ivLevel.setVisibility(View.VISIBLE);
        list.get(position).mCore.getTargetId();
        if (list.get(position).mCore.getTargetId().equals("17")) {
            ivLevel.setImageResource(R.drawable.add_ic);
        } else {
            ivLevel.setImageResource(R.drawable.search_ic);
        }
    }
}